var clbxId;
$(function () {
     clbxId = utils.getParameter("clbxId");
    $("#jqGrid").jqGrid({
        url: '../sys/user/list',
        datatype: "json",
        colModel: [			
			{ label: '用户ID', name: 'userId', index: "user_id", width: 45, key: true ,hidden:true},
            { label: '手机号', name: 'mobile', width: 100 },
            { label: '姓名', name: 'userdesc', width: 75 },
            { label: '部门', name: 'dept', width: 100 },
            { label: '部门id', name: 'deptNo', width: 100 ,hidden:true}
        ],
		viewrecords: true,
        height: 360,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page", 
            rows:"limit", 
            order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });

});

var vm = new Vue({
	el:'#rrapp',
	data:{
		q:{
			username: null
		},
		showList: true,
		title:null,
		roleList:{},
		user:{
			status:1,
			 roleIdList:[],
            name:""
		}
	},
	methods: {
		query: function () {
			vm.reload();
		},
        add:function(){
            var ids = getSelectedRows();
            if(ids == null){
                return ;
            }
                $.ajax({
                    type: "POST",
                    url: "../clbx/adduser?clbxId="+clbxId,
                    contentType: "application/json",
                    data: JSON.stringify(ids),
                    success: function(r){
                        if(r.code == 0){
                            alert('操作成功', function(index){
                                $("#jqGrid").trigger("reloadGrid");
                            });
                        }else{
                            alert(r.msg);
                        }
                    }
                });

        },
        reload: function (event) {
            vm.showList = true;
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{'username': vm.q.username},
                page:page
            }).trigger("reloadGrid");
        },


        
	}
});